/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.hostess.persistence;

import br.hostess.model.Registro;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import javax.swing.JOptionPane;

/**
 *
 * @author Marcelo Daibert
 */
public class RegistroDAO {

    public boolean salvar(Registro pRegistro) {
        System.out.println("Persistindo Objeto: " + pRegistro.toString());
        Connection objConexao = FabricaConexao.getConexao();
        try {
            Statement objSTM = objConexao.createStatement();
            objSTM.execute("INSERT INTO tbl_registro(oid, data, fk_participante, fk_evento) VALUES('" + pRegistro.getOid() + "'," + pRegistro.getData() + ",'"+pRegistro.getParticipante().getOid()+"','"+pRegistro.getEvento().getOid()+"')");
            objSTM.close();
            return true;
        } catch (Exception erro) {
            String errorMsg = "Erro ao Persistir: " + erro.getMessage();
            JOptionPane.showMessageDialog(null, errorMsg, "Mensagem", JOptionPane.ERROR_MESSAGE);
            return false;
        }

    }
   

}
